package org.jsola.hr.helper;

import org.jsola.common.SafeKit;
import org.jsola.hr.dto.SocDifferenceAddDTO;
import org.jsola.hr.dto.SocDifferenceUpdateDTO;
import org.jsola.hr.entity.SocDifferenceDO;
import org.jsola.hr.query.SocDifferenceQuery;
import org.jsola.hr.service.ISocDifferenceService;
import org.jsola.hr.vo.SocDifferenceVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.math.BigDecimal;
import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * 员工参保差额费用记录
 *
 * @author zhr
 */
@Component
public class SocDifferenceTestHelper extends BaseTestHelper {
    
    @Autowired
    private ISocDifferenceService socDifferenceService;

    /**
     * 生成add测试数据
     * @return SocDifferenceAddDTO
     */
    public SocDifferenceAddDTO getSocDifferenceAddDTO(){
        SocDifferenceAddDTO socDifferenceAddDTO = new SocDifferenceAddDTO();
        socDifferenceAddDTO.setMonthId(getRandomValue("varchar",32));
        socDifferenceAddDTO.setSocInfoId(getRandomValue("varchar",32));
        socDifferenceAddDTO.setDifferenceName(getRandomValue("varchar",50));
        socDifferenceAddDTO.setPersonalDifference(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        socDifferenceAddDTO.setCompanyDifference(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        socDifferenceAddDTO.setCompanyId(getRandomValue("varchar",32));
        socDifferenceAddDTO.setEmpId(getRandomValue("varchar",32));
        return socDifferenceAddDTO;
    }


    /**
     * 生成update测试数据
     * @return SocDifferenceUpdateDTO
     */
    public SocDifferenceUpdateDTO getSocDifferenceUpdateDTO(SocDifferenceVO socDifferenceVO){
        return socDifferenceService.selectDOById(socDifferenceVO.getId(), SITE_ID).to(SocDifferenceUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return SocDifferenceQuery
     */
    public SocDifferenceQuery getSocDifferenceQuery() {
        SocDifferenceQuery socDifferenceQuery = new SocDifferenceQuery();
        List<SocDifferenceDO> socDifferenceDOList = socDifferenceService.list(new SocDifferenceDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(socDifferenceDOList)) {
            SocDifferenceDO socDifferenceDO = socDifferenceDOList.get(0);
            socDifferenceQuery = socDifferenceDO.to(SocDifferenceQuery.class);
        }
        return socDifferenceQuery;
    }

    /**
     * 保存示例
     * @return SocDifferenceVO
     */
    public SocDifferenceVO saveSocDifferenceExample(){
        SocDifferenceAddDTO addDTO = this.getSocDifferenceAddDTO();
        SocDifferenceVO socDifferenceVO = socDifferenceService.save(addDTO,buildTokenUser());
        return socDifferenceVO;
    }


}

